#include "./static-search.h"

int binSearch(SqList &list, ElemType e)
{
	// 先定义上下限索引位置
	int low = 0, high = list.length - 1;
	// 定义中间位置
	int mid;
	while (low <= high)
	{
		mid = (high + low) / 2;
		if (list.elem[mid] == e)
		{
			return mid;
		}
		if (e > list.elem[mid])
		{
			low = mid + 1;
		}
		else
		{
			high = mid - 1;
		}
	}
	return -1;
}